import { reactive, onMounted, onBeforeUnmount } from 'vue'
export function mouseFn () {
  const mouse = reactive({
    x: 0,
    y: 0
  })
  function move (e) {
    // e.pageX,e.pageY
    mouse.x = e.pageX
    mouse.y = e.pageY
  }
  onMounted(() => {
    window.addEventListener('mousemove', move)
  })
  onBeforeUnmount(() => {
    window.removeEventListener('mousemove', move)
  })

  return mouse
}
export function addFn () {
  const state = reactive({
    count: 0
  })
  function add () {
    state.count++
  }
  return {
    state,
    add
  }
}
